//
//  CZQUnLoginAddressView.m
//  LoveBeer
//
//  Created by 崔正强 on 17/4/27.
//  Copyright © 2017年 崔正强. All rights reserved.
//

#import "CZQUnLoginAddressView.h"
#import "CZQViewController.h"
#import <Masonry.h>
#import "LoveBeer.pch"
#import "CZQAddressViewController.h"

@implementation CZQUnLoginAddressView

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self setupUI];
    }
    return self;
}

#pragma - setupUI -
- (void)setupUI {
    
    UILabel *label = [[UILabel alloc] init];
    
    [self addSubview:label];
    
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.center.equalTo(self);
    }];
    
    label.textAlignment = NSTextAlignmentCenter;
    
    label.textColor = [UIColor darkGrayColor];
    
    label.font = [UIFont systemFontOfSize:13];
    
    label.text = @"当前地址不在配送范围";
    
    UILabel *localLabel = [UILabel new];
    
    localLabel.font = [UIFont fontWithName:@"iconName" size:13];
    
    localLabel.text = @"U0000e89d";
    
    localLabel.textColor = [UIColor lightGrayColor];
    
    [localLabel sizeToFit];
    
    [self addSubview:localLabel];
    
    [localLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.equalTo(self);
        
        make.bottom.equalTo(label.mas_top).offset(-7);
    }];
    
    UIButton *btn = [[UIButton alloc] init];
    
    [self addSubview:btn];
    
    [btn setTitle:@"切换地址" forState:UIControlStateNormal];
    
    [btn setTitleColor:appColor forState:UIControlStateNormal];
    
    [btn.layer setMasksToBounds:YES];
    
    [btn.layer setCornerRadius:5.0];
    
    [btn.layer setBorderWidth:1.0];
    
    btn.layer.borderColor = appColor.CGColor;
    
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.equalTo(self);
        
        make.top.equalTo(label.mas_bottom).offset(7);
        
        make.width.mas_equalTo(140);
        
        make.height.mas_equalTo(30);
    }];
    
    [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)btnClick:(id)sender {
    
    CZQAddressViewController *VC = [[CZQAddressViewController alloc] init];
    
    [self.viewController.navigationController pushViewController:VC animated:YES];
    
}


@end
